package com.sale.salesystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sale.salesystem.entity.DashboardInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface DashboardInfoMapper extends BaseMapper<DashboardInfo> {
    
    @Select("SELECT * FROM dashboard_info WHERE owner_id = #{ownerId}")
    List<DashboardInfo> selectByOwnerId(Long ownerId);

    @Select("SELECT DISTINCT type FROM dashboard_info")
    List<String> selectAllTypes();
    
    @Select("SELECT * FROM dashboard_info WHERE status = #{status}")
    List<DashboardInfo> selectByStatus(String status);
    
    @Update("UPDATE dashboard_info SET status = #{status} WHERE id = #{id}")
    int updateStatus(Long id, String status);

    @Select("SELECT DISTINCT category FROM sales_daily_data")
    List<String> selectAllCategories();

    @Select("SELECT DISTINCT city FROM sales_daily_data")
    List<String> selectAllCities();

    List<Map<String, Object>> getRecentTotalSalesProfitData(Integer days);

    List<Map<String, Object>> getProductCategoryDistributionData();

    List<Map<String, Object>> getCustomerCityDistributionData();
} 